home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / System / VersCheck2 / Libs / mmu / ScanToConfig.rexx < prev    next >
OS/2 REXX Batch file  |  2000-01-11  |  11KB  |  285 lines

  1. /*********************************************************
  2.  ** ScanToConfig                                          **
  3.  **                                                     **
  4.  ** Builds the MMU-Configuration file automatically     **
  5.  ** from the MuScan output, including kludges for      **
  6.  ** bad or mis-designed hardware                        **
  7.  ** Version 1.01 © 1999 THOR-Software, Thomas Richter   **
  8.  ** 11.01.2000                                          **
  9.  *********************************************************/
  10.  
  11. PARSE ARG destination .
  12.  
  13.         if (destination = '') then
  14.                 destination = '*'
  15.  
  16.         
  17.         rec = 25;
  18.  
  19.         if (OPEN(.out,destination,'W')) THEN; DO
  20.                 rv=WRITELN(.out,";*************************************************************************");
  21.                 rv=WRITELN(.out,";** MMU Configuration file                                              **");
  22.                 rv=WRITELN(.out,";**                                                                     **");
  23.                 rv=WRITELN(.out,";** this file is read on startup by the mmu.library and used to modify  **");
  24.                 rv=WRITELN(.out,";** the pre-calculated or scanned MMU table                             **");
  25.                 rv=WRITELN(.out,";**                                                                     **");
  26.                 rv=WRITELN(.out,";** © 1999 THOR Software, Thomas Richter                                **");
  27.                 rv=WRITELN(.out,";*************************************************************************");
  28.                 rv=WRITELN(.out,"");
  29.                 rv=WRITELN(.out,"");
  30.                 rv=WRITELN(.out,"");
  31.                 rv=WRITELN(.out,"; the current version of the MMU library knows four commands that can");
  32.                 rv=WRITELN(.out,"; be used in this file:");
  33.                 rv=WRITELN(.out,"; CLEARTTX clears all or parts of the transparent translation registers");
  34.                 rv=WRITELN(.out,"; ADDMEM   adds memory to the exec free list pool. BE WARNED, this command");
  35.                 rv=WRITELN(.out,";          does NOT modify the MMU tables, this must be done manually with");
  36.                 rv=WRITELN(.out,";          SETCACHEMODE");
  37.                 rv=WRITELN(.out,"; SETCACHEMODE  defines the MMU tables.");
  38.                 rv=WRITELN(.out,"; DESCRIPTORCACHEINHIBIT defines whether the data cache should be disabled");
  39.                 rv=WRITELN(.out,"; for the MMU descriptors. It's usually OFF meaning the cache will remain");
  40.                 rv=WRITELN(.out,"; enabled. This is fine for the mmu.library, but certain hacks might require");
  41.                 rv=WRITELN(.out,"; an ON argument here. Note that this means more work for the library.");
  42.                 rv=WRITELN(.out,"");
  43.                 rv=WRITELN(.out,"");
  44.                 rv=WRITELN(.out,"ClearTTx        ;ignore all TTX registers if any. We don't need them");
  45.                 rv=WRITELN(.out,"");
  46.                 rv=WRITELN(.out,";DescriptorCacheInhibit ON     ;make access to MMU descriptors cache inhibited");              
  47.                 rv=WRITELN(.out,"");
  48.                 rv=WRITELN(.out,"");
  49.                 rv=WRITELN(.out,";Board specific setup follows here,");
  50.                 rv=WRITELN(.out,";generated by ScanToConfig 1.00 © 1999 THOR-Software");
  51.                 rv=WRITELN(.out,"");
  52.  
  53.         rv=WRITELN(.out,";General memory setup follows.");
  54.         rv=WRITELN(.out,";The following lines are a compatibility cludge for some P5 boards");
  55.         rv=WRITELN(.out,";which enable the MMU prior to the 68040/68060 library and leave");
  56.         rv=WRITELN(.out,";the memory in CACHEINHIBIT state. You may remove the following");
  57.         rv=WRITELN(.out,";lines on all other machines most likely.");
  58.         rv=WRITELN(.out,"");
  59.  
  60.         ADDRESS COMMAND "MemModes >T:MemInfo";
  61.         IF (OPEN(.meminfo,"T:MemInfo",'R')) THEN; DO 
  62.             DO UNTIL EOF(.meminfo)
  63.                 line = READLN(.meminfo);
  64.                 WRITELN(.out,line);
  65.             END;
  66.             rv=CLOSE(.meminfo);
  67.         END;
  68.         
  69.         rv=WRITELN(.out,";Memory setup end.");
  70.         rv=WRITELN(.out,"");
  71.         rv=WRITELN(.out,"");
  72.  
  73.         ADDRESS COMMAND 'FindPort "BOOT-MMU-Port"'
  74.         portmode = RC;
  75.  
  76.         ADDRESS COMMAND "ShowBoards to T:BoardInfo";
  77.         boards = 0;
  78.         if (OPEN(.boardinfo,"T:BoardInfo",'R')) then; do
  79.             DO UNTIL EOF(.boardinfo)
  80.                 line = READLN(.boardinfo)
  81.                 IF line ~= '' THEN; DO
  82.                     PARSE VAR line 'Type:' type 'Product:' product 'Manufacturer:' mf 'Serial#:' id 'BoardAddr:' from 'BoardSize:' size;
  83.                     boards = boards + 1;
  84.                     type.boards=X2D(type);
  85.                     product.boards=X2D(product);
  86.                     mf.boards=X2D(mf);
  87.                     id.boards=X2D(id);
  88.                     base.boards=X2D(SUBSTR(from,2,6));
  89.                     end.boards=X2D(SUBSTR(size,2,6))+base.boards;
  90.                 END
  91.             END    
  92.             rv=CLOSE(.boardinfo);
  93.         END
  94.         ADDRESS COMMAND "MuScan to T:BoardInfo";
  95.                 if (OPEN(.boardinfo,"T:BoardInfo",'R')) then; do
  96.                         rec = 0;
  97.             scan = 0;
  98.             portwarn = 0;
  99.             ppcwarn = 0;
  100.                         DO UNTIL EOF(.boardinfo)
  101.                                 line = READLN(.boardinfo)
  102.                 IF scan = 0 THEN; DO
  103.                     IF line = 'Memory map:' THEN; DO
  104.                         scan = 1;
  105.                     END;
  106.                 END; ELSE; DO
  107.                     IF line ~= '' THEN; DO
  108.                         base = SUBWORD(line,1,1);
  109.                         end  = SUBWORD(line,3,1);
  110.                         mode = SUBWORD(line,4);
  111.                         rv   = ScanEntry(base,end,mode);    
  112.                     END;
  113.                 END
  114.             END
  115.                         rv=CLOSE(.boardinfo);
  116.                 END
  117.  
  118.         IF portmode = 0 THEN;DO
  119.             rv=WRITELN(.out,"");
  120.             rv=WRITELN(.out,";Several P5 boards build a private MMU setup on boot");
  121.             rv=WRITELN(.out,";using a kludge called the BOOT-MMU-Port. To run this");
  122.             rv=WRITELN(.out,";kludge, the following external command is run from");
  123.             rv=WRITELN(.out,";LIBS:mmu/ as all other external commands");
  124.             rv=WRITELN(.out,"ScanMMUPort");
  125.             IF ~EXISTS("LIBS:mmu") THEN; DO
  126.                 OPTIONS FAILAT 15
  127.                 ADDRESS COMMAND 'MakeDir >NIL: LIBS:MMU/'
  128.                 OPTIONS FAILAT 10
  129.             END;
  130.             IF ~EXISTS("LIBS:mmu/ScanMMUPort") THEN; DO
  131.                 ADDRESS COMMAND 'Copy >NIL: ScanMMUPort to LIBS:MMU/ScanMMUPort'
  132.             END;
  133.             rv=WRITELN(.out,";SetCacheMode FROM 0xFFFF8000 SIZE 0x00008000 VALID CACHEINHIBIT");
  134.             rv=WRITELN(.out,"");
  135.         END;
  136.  
  137.     END
  138.  
  139. RETURN 0
  140.  
  141.  
  142. ScanEntry:
  143. PARSE ARG base,end,mode
  144.  
  145.     base = X2D(SUBSTR(base,3,6))
  146.     end  = X2D(SUBSTR(end,3,6))+1
  147.  
  148.     copyback     =    INDEX(mode,'CopyBack')>0;
  149.     cacheinhibit    =    INDEX(mode,'CacheInhibit')>0;
  150.     invalid        =    INDEX(mode,'Blank')>0 | INDEX(mode,'Invalid')>0;
  151.     remapped    =    INDEX(mode,'Remapped')>0;
  152.     speedup        =    INDEX(mode,'NonSerial')>0 | INDEX(mode,'Imprecise')>0;
  153.     iomark        =    0;
  154.     board        =    0;
  155.  
  156.     DO i=1 TO boards
  157.         IF base<end.i & end>base.i THEN; DO
  158.             iomark = 1;    
  159.         END;
  160.     END;
  161.     
  162.     cachemodes    =    "WriteThrough";
  163.     iomodes        =    "";
  164.     IF copyback    THEN    cachemodes="CopyBack";
  165.     IF cacheinhibit    THEN    cachemodes="CacheInhibit";
  166.     IF speedup    THEN    cachemodes="CacheInhibit Imprecise NonSerial";
  167.     IF iomark    THEN    iomodes="IOSpace";
  168.  
  169.     memrange = "SetCacheMode 0x"D2X(base)"00 Size 0x"D2X(end-base)"00";
  170.  
  171.     zeropage    =    0;
  172.     chipmem        =    0;
  173.     zorro2        =    0;
  174.     iospace        =    0;
  175.     mother        =    0;
  176.     rangermem    =    0;
  177.     p5space        =    0;
  178.     ppcspace    =    0;
  179.     mem        =    0;
  180.     rom        =    0;
  181.  
  182.     IF end<=X2D('80')                 THEN zeropage    = 1;
  183.     IF end<=X2D('2000')                THEN chipmem    = 1;
  184.     IF base>=X2D('2000')    & end<=X2D('A000')    THEN zorro2    = 1;
  185.     IF base>=X2D('A000')    & end<=X2D('B800')    THEN iospace    = 1;
  186.     IF base>=X2D('B800')    & end<=X2D('C000')    THEN mother    = 1;
  187.     IF base>=X2D('C000')    & end<=X2D('D800')    THEN rangermem    = 1;
  188.     IF base>=X2D('DA00')    & end<=X2D('E000')    THEN mother    = 1;
  189.     IF base>=X2D('E800')    & end<=X2D('F000')    THEN iospace    = 1;
  190.     IF base>=X2D('F000')    & end<=X2D('F800')    THEN p5space    = 1;
  191.     IF base>=X2D('F800')    & end<=X2D('10000')    THEN rom    = 1;
  192.     IF base>=X2D('10000')    & end<=X2D('100000')    THEN mem    = 1;
  193.     IF base>=X2D('80000')    & end<=X2D('100000')    THEN ppcspace    = 1;
  194.     IF base>=X2D('100000')    & end<=X2D('800000')    THEN iospace    = 1;
  195.     IF base>=X2D('400000')    & end<=X2D('C00000')    THEN ppcspace    = 1;
  196.     IF base>=X2D('E00000')    & end<=X2D('1000000')    THEN p5space    = 1;
  197.     IF base>=X2D('FF0000')    & end<=X2D('FF1000')    THEN iospace    = 1;
  198.     IF iomark                    THEN iospace    = 1;
  199.     
  200.     /* found remapped chip memory */
  201.     IF zeropage & remapped THEN; DO
  202.         SAY 'Found a remapped ZeroPage, it might be a good idea to run MuFastZero.';
  203.         SAY 'If MuFastZero fails with "Zero page already remapped", please add the';
  204.         SAY 'FORCENATIVE command line option.';
  205.       END;
  206.  
  207.     /* found fast chip. This can be turned on in either case */
  208.     IF chipmem & (~remapped) & (~invalid) THEN; DO
  209.         rv=WRITELN(.out,";In case you don't run the V40 68040 resp. 68060.library");
  210.         rv=WRITELN(.out,";the following line will speed up the chip memory. It is");
  211.         rv=WRITELN(.out,";not required otherwise.");
  212.         rv=WRITELN(.out,memrange "CacheInhibit Imprecise NonSerial");
  213.                   rv=WRITELN(.out,"");
  214.     END;
  215.  
  216.     /* found slow zorro II or gfx mem? */
  217.     IF zorro2 & (~copyback) & (~invalid) & (~iomark) THEN; DO
  218.         rv=WRITELN(.out,";Found slow Zorro-II memory. Keeping the caches disabled.");
  219.         rv=WRITELN(.out,memrange "CacheInhibit Imprecise NonSerial Valid");
  220.         rv=WRITELN(.out,"");
  221.     END;
  222.  
  223.     /* copy attributes for the IO space */
  224.     IF iospace & (~invalid) & (~remapped) THEN; DO
  225.         rv=WRITELN(.out,memrange cachemodes "Valid IOSpace");
  226.         rv=WRITELN(.out,"");
  227.     END;
  228.  
  229.     /* setup ranger memory */
  230.     IF rangermem & (~invalid) & (~remapped) THEN; DO
  231.         rv=WRITELN(.out,memrange "CacheInhibit Imprecise NonSerial Valid");
  232.         rv=WRITELN(.out,"");
  233.     END;
  234.  
  235.     /* setup P5 uglyness */
  236.     IF p5space & (~invalid) & (~remapped) & (~iospace) THEN; DO
  237.         rv=WRITELN(.out,";The following memory region should be left blank");
  238.         rv=WRITELN(.out,";according to the CBM design rules. It isn't...");
  239.         rv=WRITELN(.out,memrange cachemodes "Valid IOSpace");
  240.         rv=WRITELN(.out,"");
  241.     END;
  242.  
  243.     /* found remapped ROM? */
  244.     IF rom & remapped THEN; DO
  245.         SAY 'Found a remapped ROM, running MuFastRom might be a good idea,';
  246.         SAY 'but make sure you disable other ROM remappers before trying';
  247.         SAY 'to use the MMU.library setup.';
  248.     END;
  249.  
  250.     /* strange caching modes in RAM? */
  251.     IF mem THEN; DO
  252.         IF ~copyback THEN; DO
  253.             IF ~portwarn THEN; DO
  254.                 SAY 'WARNING! Found non-copyback memory regions.';
  255.                 SAY 'This could mean that either the ppc.library is running';
  256.                 SAY 'or P5 I/O hardware is active.';
  257.                 SAY 'For the time being, I do nothing about it, but you should';
  258.                 SAY 'check the MMU-Configuration file manually and follow the';
  259.                 SAY 'notes in this file for further testing.';
  260.                 rv=WRITELN(.out,"WARNING! Found non-copyback memory regions.");
  261.                 rv=WRITELN(.out,"This could mean that either the ppc.library is running");
  262.                 rv=WRITELN(.out,"or P5 I/O hardware is active.");
  263.                 rv=WRITELN(.out,"For the time being, I do nothing about it, but you could");
  264.                 rv=WRITELN(.out,"try to remove the semi-colon for the following lines:");
  265.                 portwarn = 1;
  266.             END;
  267.             rv=WRITELN(.out,";"memrange cachemodes "Valid");
  268.         END;
  269.     END;
  270.  
  271.     /* PPC memory area marked as valid? */
  272.     IF ppcspace & (~invalid) & (~remapped) THEN; DO
  273.         IF ~ppcwarn THEN; DO
  274.             SAY 'WARNING! Found possible PPC memory regions.';
  275.             SAY 'DO NOT RUN THE ppc.library or you get problems.';
  276.             ppcwarn = 1;
  277.         END;
  278.         rv=WRITELN(.out,";If you don't own a PPC, you may remove the next line:");
  279.         rv=WRITELN(.out,memrange cachemodes iomodes "Valid");
  280.         rv=WRITELN(.out,"");
  281.     END;
  282.  
  283.  
  284. RETURN 0
  285.